<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt" %>

<!DOCTYPE html>
<html>
<head>
    <title>应急预案</title>

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 引入bootstrap -->
    <link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
    <!-- 引入JQuery  bootstrap.js-->
    <script src="/js/jquery-3.2.1.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <script src="/js/jquery.easyui.min.js"></script>
    <link rel="stylesheet" href="/css/zTreeStyle.css" type="text/css">
    <script  src="/js/ztree/jquery.ztree.core.js"></script>
    <script src="/js/ztree/jquery.ztree.excheck.js"></script>
    <%--<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">--%>

</head>
<style>
    /*去掉自带的小三角*/
    details summary::-webkit-details-marker {
        display: none;
    }

    /*自定义图标，可用图片或字符,如果使用图片，请把content的值设置成空字符*/
    /*展开*/
    .menu summary:before {
        content: "+";
        /*background: url(../Images/right.png) no-repeat center center;*/ /*收起时的图片*/
        /*vertical-align: middle;*/
    }

    /*收起*/
    .menu[open] summary:before {
        content: "-";
        /*background: url(../Images/down.png) no-repeat center center;*/ /*展开时的图片*/
    }

</style>
<body>
<!-- 顶栏 -->
<jsp:include page="top.jsp"></jsp:include>
<!-- 中间主体 -->
<div class="container" style="height:100vh;">
<div class="row">

        <jsp:include page="menu.jsp"></jsp:include>


                <ul>
                    <a id="add1" class="btn btn-info" href="javascript:" role="button">增加子节点</a>
                    <a id="add2" class="btn btn-info" href="javascript:" role="button">增加兄弟节点</a>
                    <a id="edit" class="btn btn-info" href="javascript:" role="button">编辑兄弟节点内容</a>
                    <a id="edit2" class="btn btn-info" href="javascript:" role="button">编辑子节点内容</a>
                    <a id="delete" class="btn btn-info" href="javascript:" role="button">删除子节点</a>
                    <a id="delete2" class="btn btn-info" href="javascript:" role="button">删除兄弟节点</a>
                </ul>


                    <div class="col-lg-4" style="height:100vh;">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <div class="row" >
                                    <ul id="lieb" >


                                    </ul>

                                </div>
                            </div>
                        </div>
                    </div>
                    <div id="content1" style="height: 94%"> </div>
                    <div id="content2" style="height: 94%"> </div>





</div>
</div>

</body>


<script type="text/javascript">
    $(document).ready(function (){
        $("#add2").click(function () {
            window.location.href="/admin/add2edit/";

        })

          /*       $.ajax({
                     url: '',
                     type: "GET",
                     dataType: "json",
                     success: function () {

                     },
                     error: function () {
                     }
                 })*/



        $.getJSON('/eme/findall/{id}?id=1',function(data){

            var text="<details class='menu' ><summary>"+data[0].tite+"</summary><p id='lieb1'></p></details>"
            $("#lieb").after(text)
            var children = data[0].children;

            for (var i = 0; i < children.length; i++) {
             /*alert(children[i].tite)*/
                var tite=children[i].tite
                var children2="children"+i+children[i].id
                var children6="203"+children[i].id
                var text="<details class='menu'> <summary>"+tite+"</summary><ul id='"+children6+"'><li  id='"+children2+"' ><input id='"+children[i].id+"' type='hidden' value='"+children[i].id+"'><a href='javascript:'>"+tite+"</a></li></ul></details>"
                $("#lieb1").append(text)
                var children1 = children[i].children;


                $('#'+children2).click(function () {
                   var q= $(this).children("input").val();
                    $("#add1").click(function () {
                        window.location.href="/admin/add1edit/"+q;

                    })
                    $("#edit").click(function () {
                        window.location.href="/admin/editedit/"+q;

                    })
                    $("#delete2").click(function () {

                        var msg = "您真的确定要删除吗？！";
                        if (confirm(msg)==true){
                            $.ajax({
                                url: '/eme/deletenode?id='+q,
                                type: "delete",
                                success: function () {
                                    alert("删除成功")
                                    window.location.href="/admin/contingencyPlan";
                                },error: function () {
                                alert("删除失败")
                            }
                            })
                        }else{

                        }

                    })
                    $.ajax( {
                             url: '/eme/lookupcurrentcontent/{id}?id='+q,
                            type: "GET",
                            dataType: "json",
                            success: function (data) {
                                 var tite=data.tite
                                var content=data.content
                                var gmt_create=data.gmt_create
                                var gmt_modified=data.gmt_modified
                                var txt1=" <h1 id='title1' class='text-center'>"+tite+" </h1>";
                                var txt2=" <h5  >草拟人：管理员 草拟时间："+gmt_create+" 修改人：管理员 修改时间："+gmt_modified+"状态：草拟</h5>";
                                var txt3=" <h5 >-------------------------------------------------------------------------------------------------------</h5>";
                                var txt4=" <h5>"+content+" </h5>";


                                $("#content1").empty()
                                $("#content2").empty()
                                $("#content1").prepend(txt1)
                                $("#content2").prepend(txt2,txt3,txt4)
                        },
                        error: function () {
                        }
                    })

                })
                for (var a = 0; a < children1.length; a++) {
                 /*   alert(children1[i].content)*/
                    var tite=children1[a].titles
                    var children3="children2"+a+children1[a].id



                    var text="<ul ><li id='"+children3+"'><input id='"+children1[a].id+"' type='hidden' value='"+children1[a].id+"'><a href='javascript:'>"+tite+"</a></li></ul>"
                    $('#'+children6).append(text)
                    $('#'+children3).click(function () {
                        var q= $(this).children("input").val();
                        $("#edit2").click(function () {
                            window.location.href="/admin/edit2edit/"+q;

                        })
                        $("#delete").click(function () {

                                var msg = "您真的确定要删除吗？！";
                                if (confirm(msg)==true){
                                    $.ajax({
                                        url: '/eme/deletechildnode/{id}?id='+q,
                                        type: "delete",
                                        success: function () {
                                            alert("删除成功")
                                            window.location.href="/admin/contingencyPlan";
                                        },
                                        error: function () {
                                            alert("删除失败")
                                        }
                                    })
                                }else{

                                }

                        })
                        $.ajax( {
                            url: '/eme/lookupchildnode/{id}?id='+q,
                            type: "GET",
                            dataType: "json",
                            success: function (data) {
                                var tite=data.titles
                                var content=data.content
                                var keywords=data.keywords

                                var txt1=" <h1 id='title1' class='text-center'>"+tite+" </h1>";
                                var txt2=" <h5  >草拟人：管理员 修改人：管理员 关键字："+keywords+"状态：草拟</h5>";
                                var txt3=" <h5 >-------------------------------------------------------------------------------------------------------</h5>";
                                var txt4=" <h5>"+content+" </h5>";


                                $("#content1").empty()
                                $("#content2").empty()
                                $("#content1").prepend(txt1)
                                $("#content2").prepend(txt2,txt3,txt4)
                            },
                            error: function () {
                            }
                        })

                    })
                }

            }


        })

    });
    $("#nav li:nth-child(1)").addClass("active")
</script>
</html>